<template>
	<view class="page">
		<wd-navbar title="功能开关" fixed placeholder left-arrow safeAreaInsetTop custom-class="nav" :bordered="false" @click-left="handleClickLeft"></wd-navbar>
		<view class="context_box">
			 <wd-cell :title="item.title" center v-for="(item, index) in switchConfigList" :key="index">
			    <view class="custom-value" style="height: 32px;">
			      <wd-switch size="20" :active-value="STATUS.OPEN" :inactive-value="STATUS.CLOSE" active-color="#FE3D64" inactive-color="#E2E2E2" v-model="item.status" @change="handleSwitchChange(item)" />
			    </view>
			  </wd-cell>
		</view>
	</view>
</template>

<script setup>
import { toRouter } from "@/hooks/utils";
import { ref } from 'vue';
// #ifdef APP-PLUS
const jnWallpaper = uni.requireNativePlugin('jc-Wallpaper')
// #endif
const wallpaperState = ref(uni.getStorageSync('wallpaperState')?uni.getStorageSync('wallpaperState'):'CLOSE')
const wallpaperVoice = ref(uni.getStorageSync('wallpaperVoice')?uni.getStorageSync('wallpaperVoice'):'CLOSE')
const STATUS = {
	OPEN: "OPEN",
	CLOSE: "CLOSE"
}
const switchConfigList = ref([
	{
		title: '微信皮肤',
		status: STATUS.CLOSE
	},
	{
		title: 'QQ皮肤',
		status: STATUS.CLOSE
	},
	{
		title: '键盘皮肤',
		status: STATUS.CLOSE
	},
	{
		title: '壁纸声音',
		status: wallpaperVoice
	},
	{
		title: '动态壁纸',
		status: wallpaperState
	},
	{
		title: '文字锁',
		status: STATUS.CLOSE
	},
	{
		title: '动态锁屏',
		status: STATUS.CLOSE
	}
])
const handleClickLeft = function handleClickLeft() {
  uni.navigateBack()
}
const handleSwitchChange = function handleSwitchChange(item) {
	// console.log(item)
	if( plus.os.name.toLowerCase() !== "android" ){
		uni.showToast({
			title: '该功能目前只支持app',
			icon: 'none'
		})
		return;
	}
	if( item.title == '壁纸声音' ){
		if( item.status == 'CLOSE' ){
			jnWallpaper.setVolume({
			    bl: false //true 开启 false 关闭
			})
			uni.setStorageSync('wallpaperVoice', 'CLOSE')
		} else {
			uni.setStorageSync('wallpaperVoice', 'OPEN')
			jnWallpaper.setVolume({
			    bl: true //true 开启 false 关闭
			})
		}
	}
}
</script>

<style lang="scss" scoped>
:deep(.nav) {
	background: rgb(245, 245, 245) url("http://124.223.41.167:8080/mobile/static/images/bg.png") no-repeat top left/100% auto;
}
.page {
	position: relative;
	min-height: 100vh;
	--wot-cell-value-color: #979797;
	--wot-cell-title-fs: 18px;
	--wot-cell-value-fs: 18px;
	&:before {
		content: '';
		position: fixed;
		left: 0;
		top: 0;
		width: 100vw;
		height: 100vh;
		background: rgb(245, 245, 245) url("http://124.223.41.167:8080/mobile/static/images/bg.png") no-repeat top left/100%;
		z-index: -1;
	}
	:deep(.wd-cell) {
		background-color: transparent;
	}
}
</style>
